package com.wbl.train.batch.controller;

import com.wbl.train.common.feign.BusinessFeign;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * Author: 王博纶
 * Date: 2024/2/8 15:07
 * FileName: testController
 * Description: 生成火车的controller类
 */
@Slf4j
@RestController
@RequestMapping("/admin")
public class genController {

    // 注入feign的接口
    @Resource
    BusinessFeign businessFeign;

    @GetMapping("/test")
    public String test(){
        String hello = businessFeign.hello();
        log.info("businessFeign.hello() 的返回值是：{}",hello);
        return "hello world batch";
    }

    /**
     * 生成每日车次
     * @param date 要生成的日期
     */
    @GetMapping("/gen-daily/{date}")
    public boolean genTrain(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date){
        businessFeign.genTrain(date);
        return true;
    }

}
